<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/pages/inc/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>PTS专家工作台</title>
	<%@ include file="/pages/inc/header.jsp" %>
	<link rel="stylesheet" type="text/css" href="<c:url value='/styles/extends/ptsProfessor.${webConfig["csssuffix"]}'/>" media="screen, projection"/>
</head>
<body>
<%@ include file="/pages/inc/common.jsp" %>
<%@ include file="/pages/inc/menu.jsp" %>

<div class="pts-main">
	<%@ include file="/pages/inc/nav_pro.jsp" %>
	<div class="pts-page-title"><span>已承接的任务包</span></div>
	<div class="container-fluid">
	   <div id="proshow">
			<!-- 后台传值隐藏域 start-->
			<input type="hidden" id="host_serviceTaskList" value="<c:out value='${serviceTaskList}'/>">
			<!-- 后台传值隐藏域 end-->
		    <div id="service_task"  class="serviceTask_Frame"></div>
		</div>
	</div>	
	<div class="pts-page-title"><span>我的兼职历史（累计金额：￥4600.00）</span></div>
	<div class="container-fluid">
	    <ul>
	    	<li>任务名称、发包人、时间、状态、金额（元）、评价</li>
	    </ul>
	</div>
</div>
<%@ include file="/pages/inc/footer.jsp" %>
<script type="text/javascript">
	//====================================================================
	//定义模块类实例名（taskModule）、页面全局变量名（projectServiceVar）
	var projectServiceVar;

	//====================================================================

	//页面配置方法
	//author：robin
	//
	function initConfig(){
		//页面变量
		projectServiceVar = {
			//*******************************常量区******************************************//
			TASK_ZY:1,//属性说明1
			TASK_XS:"常量",//属性说明2
			//*******************************变量区******************************************//
			serviceTaskList:eval("("+$("#host_serviceTaskList").val()+")")//当前任务列表 		
		};
	}

	//单个服务任务模板生成
	//author：JCJ
	function serviceTemplate(serviceTask){
		var serviceTemplateHtml;
		var status;
		var statusName;
		var idFlag=serviceTask.taskId;
		//任务状态判断 
		 status=serviceTask.status;
		serviceTemplateHtml="<a href=\"<c:url value='/pro/workbench/"+serviceTask.projectId+"/"+status+"/"+idFlag+"'/>\"><div id=\""+idFlag+"\" class=\"service_Frame\">"+
		"<div id=\""+idFlag+"_img\" class=\"service_Template_img\">"+
		" <img alt='"+serviceTask.taskName+"' src=\"<c:url value='/images/ptService/fastGantt.png'/>\"> <div class=\"task_cost\"> 价格：￥1000 <br> 发包人："+serviceTask.personId+" </div> </div>"+
		//右面信息框 
		"<div class=\"service_Template_right\"> "+
		//任务名称行
		"<div id=\""+idFlag+"_name\" class=\"service_Template_name\">"+serviceTask.taskName+
		//任务名称结束行  
		"</div>"+
		//按钮行
		"<div id=\""+idFlag+"_button\" class=\"service_Template_button\">";
		 switch(status){
			case "0": statusName="执行中";
			break;
			case "1": statusName="待验收";
			break;
			case "2": statusName="驳回";
			break;
			case "3": statusName="待确认收款";
			break;
			case "4": statusName="交易完成";
			break;
		}
		serviceTemplateHtml += "<div id=\"service_cost\" class=\"task_status\">"+statusName+"</div>";
		//按钮结束行 
		serviceTemplateHtml += "</div>";
		//右面信息结束行  
		serviceTemplateHtml += "</div>";
		//结束行
		serviceTemplateHtml += "</div>  </a>";
		return serviceTemplateHtml;
	}

	function initHistoryTask(){
		historyTaskHtml+="<div id=\"tabs-2\" style='text-align:center'> <br />";
    	if(historytask.length==0){
    		historyTaskHtml+="<br /> <ul> <li><p>您还没有任务，赶紧行动吧, 亲... </p> </li></ul>";
	    }else{
    		historyTaskHtml+="<div class=\"service_order_tb\"> <table>";
    		historyTaskHtml+="<tr class=\"service_order_tr1\"> <th style=\"service_order_th1\">服务采购订单</th> <th>采购时间</th> <th>计划时	间</th> <th>订单状态 </th> <th>操作 </th> </tr>";
			//循环输出订单信息 
   			for(var i=0;i<historytask.length;i++){
				var createtime=historytask[i].orderTime; 		       
				var startyear=historytask[i].dueStartTime.year;
				var endyear=historytask[i].dueEndTime.year;
				var dueStartDate=null;
				var dueEndDate=null;
				if(startyear!=null){
				   startyear="2"+parseInt(startyear)-100;
				   dueStartDate=startyear+"-"+historytask[i].dueStartTime.day+"-"+historytask[i].dueStartTime.date;
				}
				if(endyear!=null){
				   endyear="2"+parseInt(endyear)-100;
				   dueEndDate=endyear+"-"+historytask[i].dueEndTime.day+"-"+historytask[i].dueEndTime.date;
				}
				historyTaskHtml+="<tr class=\"service_order_tr2\">";
				historyTaskHtml+="<td class=\"service_order_td\">"+historytask[i].orderName +"</td>";
				historyTaskHtml+="<td>"+createtime+" </td>";
				historyTaskHtml+="<td>"+dueStartDate+"至"+dueEndDate+"</td>";
				historyTaskHtml+="<td>"+serviceStatus+"</td>";
				historyTaskHtml+="<td>"+serviceOpt+"</td>";
				historyTaskHtml+="</tr>";
   			}
   			historyTaskHtml+="</table> </div>";
		}
		historyTaskHtml+="</div>";
		$("#historytask").html(historyTaskHtml);	
	}

	//初始化任务信息
	//author：JCJ
	function initServiceTask() {
		var serviceTaskHtml = "";
		var serviceTaskList = projectServiceVar.serviceTaskList;
		for ( var i = 0; i < serviceTaskList.length; i++) {
			serviceTaskHtml += serviceTemplate(serviceTaskList[i]);
		}
		$("#service_task").html(serviceTaskHtml);

	}
	//任务详情页面跳转 
	function buyExpertService(serviceID){
		window.location = '<c:url value="/serviceOrderAdd?serviceId='+serviceID+'"/>';
	}
	
	//====================================================================
	//主方法
	$(function() {
		initConfig();//初始化页面配置
		initServiceTask();//初始化服务模块
	});
</script>
</body>
</html>
